<template>
  <div id="home-content">
    <!-- 头部的轮播图 -->
    <div class="lunbo">
      <!-- <mt-swipe :auto="4000">
        <mt-swipe-item v-for="item in LunboImg" :key="item.pic">
          <img alt v-lazy="item.pic" />
        </mt-swipe-item>
      </mt-swipe>-->
      <van-swipe class="my-swipe" :autoplay="3000"  indicator-color="white">
        <van-swipe-item v-for="item in LunboImg" :key="item.pic">
          <img :src="item.pic" alt />
        </van-swipe-item>
      </van-swipe>
    </div>
    <!-- 每日推荐、歌单、排行榜 按钮 -->
    <div class="dayli-icon">
      <van-grid :border="false">
        <van-grid-item @click="dailySongs">
          <span class="glyphicon glyphicon-calendar"></span>
          <p>每日推荐</p>
        </van-grid-item>
        <van-grid-item @click="topPlaylist">
          <span class="glyphicon glyphicon-music"></span>
          <p>歌单</p>
        </van-grid-item>
        <van-grid-item @click="toplist">
          <span class="glyphicon glyphicon-stats"></span>
          <p>排行榜</p>
        </van-grid-item>
        <van-grid-item>
          <span class="glyphicon glyphicon-headphones"></span>
          <p>电台</p>
        </van-grid-item>
      </van-grid>
    </div>

    <!-- 推荐歌单-->
    <van-divider content-position="left">推荐歌单</van-divider>
    <div class="dayli">
      <!-- <info-icon :parentmsg="recommend" v-for="item in recommend" :key="item.id"></info-icon> -->
      <!-- <div class="infoIcon" v-for="item in recommend.slice(0,12)" :key="item.id"> -->
      <div class="infoIcon" v-for="info in recommend" :key="info.id">
        <div class="img">
          <img v-lazy="info.picUrl" @click="getListId(info.id)" />
        </div>
        <div class="recommend-name">
          <div class="mask"></div>
          <div class="van-ellipsis" v-text="info.name"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data: function() {
    return {
      LunboImg: [],
      recommend: [],
      cookie: "",
      // 歌单列表
      collectionList: []
    };
  },
  created() {
    //获取本地存储的cookie
    this.cookie = localStorage.getItem("cookie");
    //获取轮播图
    // console.log(cookie);
    this.$http.get("banner?type=1").then(result => {
      // console.log(result);
      // console.log(result.data.banners);
      this.LunboImg = result.data.banners;
    });
    //获取每日推荐歌单
    this.$http.get("recommend/resource?cookie=" + this.cookie).then(result => {
      // console.log(result);
      console.log(result.data.recommend);
      this.recommend = result.data.recommend;
    });
  },
  methods: {
    getListId(id) {
      this.$router.push("/PlayList/" + id);
    },
    // 跳转到每日推荐
    dailySongs() {
      this.$router.push("/dailysongs");
    },
    // 跳转到热门歌单
    topPlaylist() {
      this.$router.push("/topplaylist");
    },
    // 跳转到排行榜
    toplist() {
      this.$router.push("/toplist");
    }
  }
};
</script>

<style lang="scss">
#home-content {
  .lunbo {
    height: auto;
    img {
      width: 100%;
    }
  }
  .van-swipe__track{
    height: 38vw !important;
  }
  .dayli-title {
    margin: 0;
    font-size: 16px;
  }
  // 推荐歌单文字样式
  .van-divider {
    margin: 0;
  }
  .van-ellipsis {
    padding: 5px 10px;
  }
  .dayli {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    overflow: scroll;

    padding: 5vw;
    .infoIcon {
      width: 42.5vw;
      margin: 2.5vw 0;
      border-radius: 8px;
      box-shadow: 3px 3px 10px 3px #eee;
      font-size: 2px;
      img {
        width: 100%;
        border-radius: 8px;
      }
      //遮罩样式
      .mask {
        height: 30px;
        width: 100%;
        margin-top: -30px;
        background: rgba(255, 255, 255, 0.5);
        filter: blur(25px);
        filter: brightness(0.8);
        position: relative;
        border-radius: 0 0 8px 8px ;

      }
      .recommend-name {
        .van-ellipsis {
          margin-top: -30px;
          position: relative;
          font-size: 12px;
          color: rgb(255, 255, 255);
        }
      }
    }
  }
  //四宫格样式
  .dayli-icon {
    margin: 0;
    padding: 0;
    span {
      font-size: 5vw;
      background: #eee;
      padding: 3vw;
      border-radius: 50%;
    }
    p {
      font-size: 2vw;
      line-height: 10vw;
      margin: 0;
    }
  }
}
</style>